package com.tv.nextin;


import com.tv.nextin.Utils.Common;
import com.tv.nextin.bean.Person;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class BookingAppointmentActivity extends Activity implements OnTouchListener {

	TextView title;
	ImageButton btnBack;
	Person person = new Person();
	
	TextView txtMyName, txtMyEmail, txtMyPhone;
	Button btnOk;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_booking_appointment);
		
		person = getIntent().getParcelableExtra("person");
		
		title = (TextView) findViewById(R.id.title);
		btnBack = (ImageButton) findViewById(R.id.btn_back);
		btnBack.setVisibility(View.VISIBLE);
		
		btnOk = (Button) findViewById(R.id.btn_ok);
		
		txtMyName = (TextView) findViewById(R.id.txt_my_name);
		txtMyEmail = (TextView) findViewById(R.id.txt_my_email);
		txtMyPhone = (TextView) findViewById(R.id.txt_my_phone);
		
		init();
	}

	
	void init(){
		title.setText("Booking Appointment");
		btnBack.setOnTouchListener(this);
		txtMyName.setText(person.getName());
		txtMyEmail.setText(person.getEmail());
		txtMyPhone.setText(person.getPhone());
		btnOk.setOnTouchListener(this);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		switch (v.getId()) {
		case R.id.btn_back:
			if (event.getAction() == MotionEvent.ACTION_UP){
				closeActivity();
			}
			break;
		case R.id.btn_ok:
			if (event.getAction() == MotionEvent.ACTION_UP){
				finish();
				closeActivity();
				Intent broadcastIntent = new Intent();
				broadcastIntent.setAction(Common.FINISH);
				sendBroadcast(broadcastIntent);
			}
			break;
		default:
			break;
		}
		return false;
	}
	
	void closeActivity(){
		finish();
		overridePendingTransition(R.anim.over_main_right, R.anim.trans_right_out);
	}
	
	
	@Override
	public void onBackPressed() {
		closeActivity();
	}
}
